import requests
import re
from urllib3.exceptions import InsecureRequestWarning
import datetime

Platform = "暴走2_魔情书斋"
today = datetime.date.today()  # 今天
yester = today - datetime.timedelta(days=1)


def baozou2():
    try:
        requests.urllib3.disable_warnings(InsecureRequestWarning)
        r = requests.session()
        url = "https://www.bzcps.com/admin/checklogin.html"
        date = {
            "account": "",
            "password": ""
        }
        r.post(url=url, data=date, verify=False, timeout=15)
        aa = r.get(url="https://www.bzcps.com/index/report/dayincome.html", verify=False, timeout=15)
        aa = aa.text.replace('\n', '').replace('\t', '').replace('\r', '')
        date_time = str(yester)
        Amount_share = re.findall('昨日分成.*?￥</em>(.*?)</p>', aa)[0]
        return date_time, Amount_share, Platform
    except (KeyError, ValueError, TypeError, IndexError):
        print("获取 暴走2_魔情书斋 数据失败")
        return '', 'None', Platform
    except ConnectionError:
        print("获取 暴走2_魔情书斋 数据 超时")
        return '', 'None', Platform
